// index.js
// 获取应用实例
const App = getApp()
const api = require('../../utils/requst.js').API;
Page({
  data: {
   top:20,
   inline:true,
   current: '1',
   height:'auto',
   dd:{}
  },
  onLoad(e) {
    console.log(e)
    let top =App.globalData.systemInfo.statusBarHeight + 6
    let height = App.globalData.systemInfo.screenHeight-60
   this.setData({top,height})
   api.getPageTeacherList({id:e.id}).then(res=>{
     this.setData({dd:res.data.data.records[0]})
   })
  },
  tobuy(e){
    console.log(e)
    let price =  e.currentTarget.dataset['price'];
    let isAlone =  e.currentTarget.dataset['alone'];
    console.log(isAlone)
    wx.navigateTo({
      url: '../pusht/index?id='+this.data.dd.id+'&name='+this.data.dd.teacherName+'&teacherProfe='+this.data.dd.teacherProfe+'&isAlone='+isAlone+'&price='+price,
    })
  },
  handleChange ({ detail }) {
    console.log(detail.key)
    this.setData({
        current: detail.key
    });
  },
  callPhone(e){
    let phone =  e.currentTarget.dataset['phone'];
    wx.makePhoneCall({
      phoneNumber: phone
    })
  },
  saveCollect(){
    api.saveCollect({collectType:1,id:this.data.dd.id,teacherId:this.data.dd.id,userId:wx.getStorageSync('token')}).then(res=>{
      wx.showToast({
        title: '收藏成功',  // 标题
        icon: 'success',   // 图标类型，默认success
        duration: 1500   // 提示窗停留时间，默认1500ms
    })
    })
  },
  back(){
    wx.navigateBack({
      delta: 1,
    })
  }
})
